package com.siyu.basedata.wrprsrbsin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.siyu.basedata.wrprsrbsin.domain.WrpRsrBsin;
import com.siyu.basedata.wrprsrbsin.service.IWrpRsrBsinService;

/**
 * 水库基础信息Controller
 *
 * @author hrhy
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/basedata/bsin")
public class WrpRsrBsinController extends BaseController {
    @Autowired
    private IWrpRsrBsinService wrpRsrBsinService;

    /**
     * 查询水库基础信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WrpRsrBsin wrpRsrBsin) {
        startPage();
        List<WrpRsrBsin> list = wrpRsrBsinService.selectWrpRsrBsinList(wrpRsrBsin);
        return getDataTable(list);
    }

    /**
     * 导出水库基础信息列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, WrpRsrBsin wrpRsrBsin) {
        List<WrpRsrBsin> list = wrpRsrBsinService.selectWrpRsrBsinList(wrpRsrBsin);
        ExcelUtil<WrpRsrBsin> util = new ExcelUtil<WrpRsrBsin>(WrpRsrBsin.class);
        util.exportExcel(response, list, "水库基础信息数据");
    }

    /**
     * 获取水库基础信息详细信息
     */
    @GetMapping(value = "/{rscd}")
    public AjaxResult getInfo(@PathVariable("rscd") String rscd) {
        return success(wrpRsrBsinService.selectWrpRsrBsinByRscd(rscd));
    }

    /**
     * 新增水库基础信息
     */
    @PostMapping
    public AjaxResult add(@RequestBody WrpRsrBsin wrpRsrBsin) {
        return toAjax(wrpRsrBsinService.insertWrpRsrBsin(wrpRsrBsin));
    }

    /**
     * 修改水库基础信息
     */
    @PutMapping
    public AjaxResult edit(@RequestBody WrpRsrBsin wrpRsrBsin) {
        return toAjax(wrpRsrBsinService.updateWrpRsrBsin(wrpRsrBsin));
    }

    /**
     * 删除水库基础信息
     */
    @DeleteMapping("/{rscds}")
    public AjaxResult remove(@PathVariable String[] rscds) {
        return toAjax(wrpRsrBsinService.deleteWrpRsrBsinByRscds(rscds));
    }
}
